new Vue({
    el: '#app',
    data() {
      return {
        form: {
          Data:'function_approval_config',
          Primary_Key:'',
          Primary_Key_Name:'Function_Approval_Name',
          isVague:true,
          Row_Status:false,
          page: 1,			//页数
          limit: 10,			//每页数据条数
        },
        total: 0,
        tableData: [],		//表格数据
      }
    },
    mounted() {
      this.getList(this.form)
    },
    methods: {
      onSerach() {				//查询方法
        this.form.page = 1;
        this.getList(this.form)
      },
      Add() {
        window.location.href = './Add.html'
      },
      handleSizeChange(val) {
        this.form.page = 1;
        this.form.limit = val;
        this.getList(this.form)
      },
      handleCurrentChange(val) {
        this.form.page = val;
        this.getList(this.form)
      },
      getList(data) {     //换页方法
        let _this = this
        $.ajax({
          type: 'POST',
          url: `${DomainName}/getTableInquiryAction?token=${$.cookie('token')}`,
          data,
          complete: function (XMLHttpRequest) {
            if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
              window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
            }
          },
          success: function (Result) {
            if(Result.Status=='success'){
              _this.tableData = Result.tableData
              _this.total = parseInt(Result.limit)
            }
          },
          dataType: "json"
        });
      },
      Edit(Function_Approval_SerialNumber) {
        sessionStorage.setItem("Function_Approval_SerialNumber", Function_Approval_SerialNumber)
        window.location.href = './Edit.html?Function_Approval_SerialNumber=' + Function_Approval_SerialNumber
      },
      Delete(row) {
        const _this = this
        this.$confirm(row.Row_Status=='0'?'警告！此操作将停用此功能, 是否继续?':'此操作将恢复此功能, 是否继续?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning',
        }).then(() => {
          $.ajax({
            url: DomainName + '/DeleteAction?token=' +$.cookie('token'),
            type: 'POST',
            data:{
              TableName:'function_approval_config',
              Primary_Key:row.Function_Approval_SerialNumber,
              Primary_Key_Name:'Function_Approval_SerialNumber',
              Row_Status:row.Row_Status == '0'?'1':'0',
              Operation_Name:row.Row_Status=='0'?'停用功能':'恢复功能'
            },
            success: function (res) {
              if (res.Status == 'success') {
                _this.getList(_this.form);
                _this.$message({
                  type: 'success',
                  message: row.Row_Status=='0'?'停用成功!':'恢复成功!'
                });
              }
            },
            complete: function (XMLHttpRequest) {
              if (XMLHttpRequest.getResponseHeader("REDIRECT") == "REDIRECT") {
                window.parent.document.location.href = absolutepath() + XMLHttpRequest.getResponseHeader("CONTENTPATH");
              }
            }
          })
        }).catch(() => {
          this.$message({
            type: 'warning',
            message: '已取消操作'
          });
        });
      },
    },
  })